package activity;

import edos.prm.metrics.MetricExpression;

/**
 * The {@code BalloonKPI} keeps track of the total number of balloons consumed
 * since the process was first scheduled.
 */
public final class BalloonKPI implements MetricExpression {

	private int numberOfBalloonsConsumed;
	
	/**
	 * Create a BalloonKPI (metric)
	 */
	public BalloonKPI() {
		this.numberOfBalloonsConsumed = 0;
		System.out.println("ABZ: .... Balloon KPI is created");
	}
	
	/**
	 * Called each time that a consume operation is invoked. This is an
	 * operational metric.
	 * 
	 * args the arguments to the consumeBalloons operation.
	 */
	public void evaluate(Object...args) {
		Integer number = (Integer) args[1];
		this.numberOfBalloonsConsumed += number;
		System.out.print(" >>>> KPI: Balloons consumed now is "
				+ this.numberOfBalloonsConsumed + " <<<< ");
	}

	/**
	 * Metric returns the number of balloons consumed since the start.
	 * 
	 * @return the current value of the metric as a Number
	 */
	public Number getMeasure() {
		System.out.print(" >>>> KPI: called getMeasure()");
		return new Integer(this.numberOfBalloonsConsumed);
	}
}
